<?php
/**
 * them anh cho product
 * @param array $params 
 *      array(`uid`, `filename`, `filepath`, `filemime`, `filesize`, `status`, `timestamp`, `pid`)
 * @return int last insert id
 * @author anhmantk
 * @date Dec 29, 2011
 */
function insertPictureForProduct($params = array()) {
    global $user;
    $query = "INSERT INTO {files} (`uid`, `filename`, `filepath`, `filemime`, `filesize`, `status`, `timestamp`, `pid`) VALUES (%d, '%s', '%s', '%s', %d, %d, %d, %d)";    
    if (db_query($query, $params)) {
        return db_last_insert_id('files', 'fid');
    }
    return -1;
}